export class Vector2 {
    public x: number;
    public y: number;

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }
    public static add(a: Vector2, b: Vector2): Vector2 { return new Vector2(a.x + b.x, a.y + b.y); }
    public static dot(a: Vector2, b: Vector2): number { return a.x * b.x + a.y * b.y; }
    public static cross(a: Vector2, b: Vector2): number { return a.x * b.y - a.y * b.x; }
    public static sub(a: Vector2, b: Vector2): Vector2 { return new Vector2(a.x - b.x, a.y - b.y); }
    public static getLength(a: Vector2): number { return Math.sqrt(a.x * a.x + a.y * a.y); }
    public static normalize(a: Vector2): Vector2 {
        let len = Vector2.getLength(a);
        return new Vector2(a.x / len, a.y / len);
    }

}